package com.peng.rockermq;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;

/**
 * Provider
 *
 * @author: lupeng6
 * @create: 2021/4/15 18:38
 */
public class Provider {

    public static void main(String[] args) throws MQClientException, RemotingException, InterruptedException, MQBrokerException {
        DefaultMQProducer producer = new DefaultMQProducer("hello-rocketmq");
        producer.setNamesrvAddr("localhost:9876");
        producer.start();
        producer.setSendMsgTimeout(3000);


        for (int i = 0; i < 100; i++) {
            Message msg = new Message("first-topic", ("hello" + i).getBytes());
            SendResult result = producer.send(msg);
            System.out.println(result);
        }

        System.out.println("shoutDown");
        producer.shutdown();
    }



}
